package czy.demo.component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
public class ApplicationArgumentsComponent implements InitializingBean {

    private static final Logger logger = LoggerFactory.getLogger(ApplicationArgumentsComponent.class);

    /* 注入应用程序参数 */
    @Autowired
    private ApplicationArguments arguments;

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("应用程序参数为："+Arrays.toString(arguments.getSourceArgs()));
    }
}
